/**
 * 
 */
var url = "index.jsp?inc=./member/";


function general() {

	if(document.getElementById('btnCancle') != null){
		document.getElementById('btnCancle').onclick = function(){
			var b = confirm("정말 취소를 하시겠습니까?");
			if(b) {
				location.href = "index.jsp?inc=./mainContent.jsp";
			}		
		}
	}
	
	if(document.getElementById('btnMain') != null){
		document.getElementById('btnMain').onclick = function(){
			location.href = "index.jsp?inc=./mainContent.jsp";
		}
	}
	
	
	if(document.getElementById('btnLogin') != null){
		document.getElementById('btnLogin').onclick = function(){
			var frm = document.loginFrm;
			if(frm.mid.value == "" || frm.pwd.value == ""){
				alert("작성하지 않은 빈 항목이 존재합니다.");
			}else{
				frm.action = url + 'loginResult.jsp';
				frm.submit();
			}
			
			
		}
		
	}
	
	
	
	
	if(document.getElementById('btnJoin') != null){
		document.getElementById('btnJoin').onclick = function() {
			var frm = document.joinFrm;
			if(frm.overlap.value != "사용 가능한 아이디입니다."){
				alert("아이디 중복검사가 되지 않았습니다.");
							
			}else{
				if(frm.mid.value == "" || frm.pwd.value == "" || frm.pwd2.value == "" ||
				   frm.irum.value == "" || frm.pn2.value == "" || frm.pn3.value =="" ||
				   frm.answer.value == ""){
					
					alert("작성하지 않은 빈 항목이 존재합니다.");
					
					if(frm.mid.value == ""){
						frm.mid.focus();
					}else if(frm.pwd.value == ""){
						frm.pwd.focus();
					}else if(frm.pwd2.value == ""){
						frm.pwd2.focus();
					}else if(frm.irum.value == ""){
						frm.irum.focus();
					}else if(frm.pn2.value == ""){
						frm.pn2.focus();
					}else if(frm.pn3.value == ""){
						frm.pn3.focus();
					}else if(frm.answer.value == ""){
						frm.answer.focus();
					}
					
				}else{
					
					if(frm.pwd.value != frm.pwd2.value){
						alert("비밀번호가 일치하지 않습니다.");
					}else{
						frm.action = url + 'joinResult.jsp';
						frm.submit();
					}
				}
			}
		}
	}
	
	
	
	if(document.getElementById('btnContinue') != null){
		document.getElementById('btnContinue').onclick = function(){
			var frm = document.modiFrm;
			
			if(frm.pwd.value == ""){
				
				alert("비밀번호를 입력하세요.");
				
				frm.pwd.focus();
				
			}else{
				if(frm.pwd.value != frm.hPwd.value){

					alert("비밀번호가 일치하지 않습니다.");
					frm.pwd.value = "";
					frm.pwd.focus();	
					
				}else{
					frm.action = url + 'modifyMember.jsp';
					frm.submit();

				}
			}
			
		}
	}
	
	
	
	if(document.getElementById('btnModify') != null){
		document.getElementById('btnModify').onclick = function() {
			
			var frm = document.modifyFrm;
			
			if(frm.mid.value == "" || frm.pwd.value == "" || frm.pwd2.value == "" ||
			   frm.irum.value == "" || frm.pn2.value == "" || frm.pn3.value =="" ||
			   frm.answer.value == ""){
				
				alert("작성하지 않은 빈 항목이 존재합니다.");
				
				if(frm.mid.value == ""){
					frm.mid.focus();
				}else if(frm.pwd.value == ""){
					frm.pwd.focus();
				}else if(frm.pwd2.value == ""){
					frm.pwd2.focus();
				}else if(frm.irum.value == ""){
					frm.irum.focus();
				}else if(frm.pn2.value == ""){
					frm.pn2.focus();
				}else if(frm.pn3.value == ""){
					frm.pn3.focus();
				}else if(frm.answer.value == ""){
					frm.answer.focus();
				}
				
			}else{
				
				if(frm.pwd.value != frm.pwd2.value){
					alert("비밀번호가 일치하지 않습니다.");
				}else{
					frm.action = url + 'modifyResult.jsp';
					frm.submit();
				}
			}
		}
	}
		

	if(document.getElementById('btnDelete') != null){
		document.getElementById('btnDelete').onclick = function(){
			var frm = document.deleteFrm;
			
			if(frm.pwd.value == ""){
				
				alert("비밀번호를 입력하세요.");
				
				frm.pwd.focus();
				
			}else{
				if(frm.pwd.value != frm.hPwd.value){

					alert("비밀번호가 일치하지 않습니다.");
					frm.pwd.value = "";
					frm.pwd.focus();	
					
				}else{
					var b = confirm("정말 회원탈퇴를 하시겠습니까?");
					if(b) {
						frm.action = url + 'deleteResult.jsp';
						frm.submit();
						
					}
				}
			}
			
		}
	}
	
	

	
	
	
}


function joinInit() {
	document.getElementById('btnId').onclick = function(){
		var frm = document.joinFrm;

		frm.action = url + 'overlap.jsp';
		frm.submit();

	}
	
	general();
}

function overlapInit() {
	var frm = document.overlapFrm;
	frm.action = url + 'joinMember.jsp';
	frm.submit();
}

function modifyInit() {
	general();
}

function resultInit(){
	general();
}

function deleteInit(){
	general();
}

function loginInit(){
	general();
}

function loginResultInit(){
	var frm = document.loginFrm;
	
	if(frm.mid == null){
		location.href = url + 'loginMember.jsp';
	}else{
		location.href = './index.jsp';
	}
	
	
}

function logoutInit(){
	location.href = './index.jsp';	
}
